import { http } from "@/utils/http";

export const useUploadAPI = () => {
  /**
   * 通用文件上传接口
   * @param file 文件对象
   * @returns Promise
   */
  const uploadFile = (file: File): Promise<any> => {
    const formData = new FormData();
    formData.append("file", file);

    return http.post("/upload", formData, {
      headers: {
        "Content-Type": "multipart/form-data",
      },
    });
  };

  return {
    uploadFile,
  };
};
